package com.example.yunifang;


import com.example.yunifang.adapter.MyWelcomeAdapter;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.Menu;
import android.view.Window;

public class MainActivity extends Activity {

    private ViewPager vp;
    private Handler handler=new Handler(){
    	public void handleMessage(android.os.Message msg) {
    		SharedPreferences sp=getSharedPreferences("main", MODE_PRIVATE);
			Editor editor=sp.edit();
			editor.putBoolean("sss", true);
			editor.commit();
    		if(msg.what==1){
    			Intent intent=new Intent(MainActivity.this,ZhuActivity.class);
    			startActivity(intent);
    			overridePendingTransition(R.anim.outactivity, R.anim.inactivity);
    			finish();
    		}
    	};
    	
    };


	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        vp=(ViewPager)findViewById(R.id.vp);
        vp.setAdapter(new MyWelcomeAdapter(this));
        vp.setOnPageChangeListener(new OnPageChangeListener() {
			
			@Override
			public void onPageSelected(int arg0) {
				// TODO Auto-generated method stub
				switch (arg0) {
				case 4:
					handler.sendEmptyMessageDelayed(1, 000);

				default:
					break;
				}
			}
			
			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				
			}
		});
        //vp.setPageTransformer(true, new ZoomOutPageTransformer());
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    @Override
    protected void onDestroy() {
    	// TODO Auto-generated method stub
    	super.onDestroy();
    	
    }
    
}
